<template>
	<view>
		<u-navbar :border-bottom="false" title="学习详情" title-color="#fff" back-icon-color="#fff"></u-navbar>
		<view  class="subList">
			<view  @click="subItemClick(item.resourceId)" class="subItem" v-for="(item,subIndex) in subItem" :key="subIndex">
				<view class="subItemLeft">
					<image :src="item.thumbnail"></image>
					<view class="subContent">
						<text>{{item.resourceName}}</text>
					</view>
					<view class="subItemTime">{{item.videoDuration}}</view>
				</view>
				<view class="subItemRight">
					<view class="subjectTit">{{item.subName}}</view>
					<view class="subjectTxt">
						<view v-if="item.process !=100" class="subStata" :class="[item.process==100?'stataAll':'']">未看完</view> 
						<view v-if="item.process ==100" class="subStata" :class="[item.process==100?'stataAll':'']">已看完</view>
						<view v-if="item.process !=100">观看至：{{item.process}}%</view>
					</view>
					<view class="subTime">最近一次看完：{{item.lastTime}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				subTitle:'',//名称
				subItem:'',//科目列表
				userId:'',//ID
			};
		},
		onLoad(options){
			// this.getClassList(options.userId)
			this.userId=options.userId
		},
		onShow(){
			this.getClassList()
		},
		methods:{
			// 刷新
			handleRefresh(){
				return this.getClassList()
			},
			getClassList(id){
				//课程列表
				return new Promise((resolve, reject) => {
					this.request
						.get(`/app/teacher/home/studyProcessDetail/${this.userId}`)
						.then(res => {
							this.subItem=res;
							resolve();
						})
						.catch(reject);
				});
			},
			// 点击跳转
			subItemClick(data){
				uni.navigateTo({
					url:'../classroom/subjectDetail?resourceId='+data
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.subItem{
		display: flex;
		justify-content: space-between;
		// width: 100%;
		margin: 0 30upx;
		padding: 30upx 0;
		border-bottom: 1px solid #EBEBEB;
	}
	.subContent{
		display: flex;
		justify-content: center;
		align-items: center;
		width: 100%;
		height: 100%;
		position: absolute;
		top: 0;
		left: 0;
		color: white;
		text {
			display: block;
			text-align: center;
			font-size: 32upx;
			font-weight: 600;
			overflow: hidden;
			width: 221upx;
			max-height: 80upx;
			line-height: 40upx;
			vertical-align: middle;
		}
	}
	.subItemLeft{
		position: relative;
				width: 286upx;
				height: 176upx;
		    margin-right: 29upx;
		    border-radius: 10upx;
		    overflow: hidden !important;
				image{
					border-radius: 10upx;
					width: 100%;
					height: 100%;
				}
	}
	.subItemLeft.subActive::before{
	   	content: 'new';
	   	position: absolute;
	   	top: 0;
	   	left: 0;
	   	height: 30upx;
	   	line-height: 30upx;
	   	padding: 0upx 16upx 0 10upx;
			border-radius: 10upx 0 0 0;
	   	text-align: center;
	   	background: $linear-bg;
	   	clip-path: polygon(0% 0%, 0% 100%, calc(100% - 10upx) 100%, 100% 0%);
	   	font-size: 22upx;
	   	font-weight: 400;
	   	color: #ffffff;
	   	z-index: 1;
	}
	.subItemTime{
		position: absolute;
		right: 15upx;
		top: 15upx;
		background: rgba(255,255,255,.15);
		color: #fff;
		font-size: 20upx;
		padding: 0 10upx;
		border-radius: 7upx;
	}
	.subjectTit{
		color: #363940;
		font-size: 32upx;
		line-height: 70upx;
	}
	.subjectTxt{
		color: #A6A6A6;
		font-size: 24upx;
		display: flex;
		justify-content: start;
		align-items: center;
		overflow: hidden;
		margin-top: 20upx;
		margin-bottom: 20upx;
	}
	.subItemRight{
		width: 400upx;
	}
	.stataAll{
		border: 1px solid #3F7BF2!important;
		color: #3F7BF2!important;
	}
	.subStata{
		width: 90upx;
		height: 36upx;
		line-height: 34upx;
		text-align: center;
		border: 1px solid #F99D2E;
		border-radius: 6upx;
		color: #F99D2E;
		font-size: 24upx;
		margin-right: 25upx;
	}
	.subTime{
		color: #A6A6A6;
		font-size: 24upx;
	}
	.content {
		width: 100%;
		height: 100%;
		position: absolute;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		top: 0;
		left: 0;
		color: white;
		text {
			display: block;
			text-align: center;
			font-size: 32upx;
			font-weight: 600;
			overflow: hidden;
			margin: 51upx auto 0;
			width: 221upx;
			max-height: 80upx;
			line-height: 40upx;
			vertical-align: middle;
		}
	}
</style>
